//
//  TLSoundPlayer.h
//  KidReading
//
//  Created by telen on 14/12/29.
//  Copyright (c) 2014年 刘赞黄Telen. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>

@protocol TLSoundPlayerDelegate <NSObject>

@optional
- (void)tlSoundPlayerDidFinishPlayingFile:(NSString*)fileFullPath;
- (void)tlSoundPlayerDidFinishPlayingFile:(NSString*)fileFullPath player:(AVAudioPlayer *)player;
//
- (void)tlSoundPlayerDidFinishPlayingArr:(NSArray*)fullPathArr withSign:(NSString*)sign;
- (void)tlSoundPlayerDidStartPlayingArr:(NSArray*)fullPathArr withSign:(NSString*)sign;
//
- (void)tlSoundActionToStop_PlayingFile:(NSString*)fileFullPath;//用户调用了

@end

@interface TLSoundPlayer : NSObject<AVAudioPlayerDelegate>
{
    NSMutableDictionary* playDict;
    //
    NSMutableDictionary* playArrDict;
    NSArray* playArr;
}

+(TLSoundPlayer*)shareSingle;

- (BOOL)prepareToPlayFile:(NSString*)fileFullPath fromTime:(NSTimeInterval)ftime;
- (BOOL)prepareToPlayFile:(NSString*)fileFullPath andDelegate:(id<TLSoundPlayerDelegate>)delegate;
- (BOOL)playFile:(NSString*)fileFullPath andDelegate:(id<TLSoundPlayerDelegate>)delegate;
- (BOOL)rePlayFile:(NSString *)fileFullPath andDelegate:(id<TLSoundPlayerDelegate>)delegate;
- (BOOL)playFile:(NSString *)fileFullPath fromTime:(NSTimeInterval)ftime andDelegate:(id<TLSoundPlayerDelegate>)delegate;
- (BOOL)stopFilePlay:(NSString*)fileFullPath;
- (BOOL)stopFilePlay_andClean:(NSString*)fileFullPath;
- (void)stopAllFiles;
- (void)stopAllFiles_andClean;
- (BOOL)isFilePlaying:(NSString*)fileFullPath;

- (NSTimeInterval)getPlayProgressForFile:(NSString*)fileFullPath;

//可以提供给控制UI
- (AVAudioPlayer*)getAudioPlayerForPlayFile:(NSString *)fileFullPath;

//词组发声 短音
- (void)playSoundArr:(NSArray *)fullPathArr andDelegate:(id<TLSoundPlayerDelegate>)delegate withSign:(NSString*)sign;

@end
